package com.rui.sideup.module.codegen.core.model;

import java.util.ArrayList;
import java.util.List;

public class Table implements Cloneable {

    private String name;

    private String clazzName;

    private String camelClazzName;

    private String type;

    private String comment;

    private List<Column> columns;

    private Column primaryKey;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getClazzName() {
        return clazzName;
    }

    public void setClazzName(String clazzName) {
        this.clazzName = clazzName;
    }

    public String getCamelClazzName() {
        return camelClazzName;
    }

    public void setCamelClazzName(String camelClazzName) {
        this.camelClazzName = camelClazzName;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public List<Column> getColumns() {
        return columns;
    }

    public void setColumns(List<Column> columns) {
        this.columns = columns;
    }

    public Column getPrimaryKey() {
        return primaryKey;
    }

    public void setPrimaryKey(Column primaryKey) {
        this.primaryKey = primaryKey;
    }

    @Override
    public String toString() {
        return "Table{" +
                "name='" + name + '\'' +
                ", clazzName='" + clazzName + '\'' +
                ", camelClazzName='" + camelClazzName + '\'' +
                ", type='" + type + '\'' +
                ", comment='" + comment + '\'' +
                ", columns=" + columns +
                ", primaryKey=" + primaryKey +
                '}';
    }

    @Override
    public Table clone()  {
        Table t = null;
        try {
            t = (Table) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }

        List<Column> cols = (List) ((ArrayList) t.getColumns()).clone();
        t.setColumns(cols);

        return t;
    }
}
